<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>折叠扇轮播</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #f0f0f0;
            perspective: 1000px;
        }

        .fan-carousel {
            width: 800px;
            height: 500px;
            position: relative;
            transform-style: preserve-3d;
        }

        .fan-container {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            transition: transform 0.8s ease;
        }

        .fan-item {
            position: absolute;
            width: 20%;
            height: 100%;
            overflow: hidden;
            transform-origin: left center;
            transition: all 0.8s ease;
            transform-style: preserve-3d;
        }

        .fan-item img {
            width: 500%;
            height: 100%;
            object-fit: cover;
            position: absolute;
            left: 0;
            top: 0;
            pointer-events: none;
        }

        .controls {
            position: fixed;
            bottom: 20px;
            display: flex;
            gap: 10px;
            z-index: 100;
        }

        .control-btn {
            padding: 10px 20px;
            background: #333;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background 0.3s;
        }

        .control-btn:hover {
            background: #555;
        }
    </style>
</head>
<body>
    <div class="fan-carousel">
        <div class="fan-container">
            <div class="fan-item" style="left: 0%"><img src="../img/1 (1).png" alt="Image 1"></div>
            <div class="fan-item" style="left: 20%"><img src="../img/1 (2).png" alt="Image 2" style="left: -100%"></div>
            <div class="fan-item" style="left: 40%"><img src="../img/1 (3).png" alt="Image 3" style="left: -200%"></div>
            <div class="fan-item" style="left: 60%"><img src="../img/1 (4).png" alt="Image 4" style="left: -300%"></div>
            <div class="fan-item" style="left: 80%"><img src="../img/1 (5).png" alt="Image 5" style="left: -400%"></div>
        </div>
    </div>
    <div class="controls">
        <button class="control-btn prev">上一张</button>
        <button class="control-btn next">下一张</button>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const container = document.querySelector('.fan-container');
            const items = document.querySelectorAll('.fan-item');
            const prevBtn = document.querySelector('.prev');
            const nextBtn = document.querySelector('.next');
            
            let currentIndex = 0;
            const totalItems = items.length;
            let isAnimating = false;

            function updateCarousel() {
                if (isAnimating) return;
                isAnimating = true;

                items.forEach((item, index) => {
                    const angle = index === currentIndex ? 0 : 60;
                    item.style.transform = `rotateY(${angle}deg)`;
                });

                container.style.transform = `translateX(${-currentIndex * 20}%)`;

                setTimeout(() => {
                    isAnimating = false;
                }, 800);
            }

            prevBtn.addEventListener('click', () => {
                if (!isAnimating) {
                    currentIndex = (currentIndex - 1 + totalItems) % totalItems;
                    updateCarousel();
                }
            });

            nextBtn.addEventListener('click', () => {
                if (!isAnimating) {
                    currentIndex = (currentIndex + 1) % totalItems;
                    updateCarousel();
                }
            });

            // Initialize carousel
            updateCarousel();

            // Auto play
            setInterval(() => {
                if (!isAnimating) {
                    currentIndex = (currentIndex + 1) % totalItems;
                    updateCarousel();
                }
            }, 3000);
        });
    </script>
</body>
</html>